using System;
using System.Data;
using System.Data.OleDb;
using System.Collections;
using System.Configuration;
using System.Runtime.InteropServices;

//Using PCS's namespaces 
using PCSComUtils.DataAccess;
using PCSComUtils.PCSExc;
using PCSComUtils.Common;

namespace PCSComProduction.ValueAddTransact.DS
{
	public class PRO_OutsideProcessingMasterDS //: PCSComUtils.Generic.IObjectDS 
	{
		#region Declaration, Constructor
		
		private const string THIS = "PCSComProduction.ValueAddTransact.DS.PRO_OutsideProcessingMasterDS";

		public PRO_OutsideProcessingMasterDS()
		{

		}
		
		#endregion Declaration, Constructor

		#region Update Data Methods
		
		//**************************************************************************              
		///    <Description>
		///       This method uses to add data to PRO_OutsideProcessingMaster
		///    </Description>
		///    <Inputs>
		///        PRO_OutsideProcessingMasterVO       
		///    </Inputs>
		///    <Outputs>
		///       newly inserted primarkey value
		///    </Outputs>
		///    <Returns>
		///       void
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       Tuesday, May 31, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************


		public void Add(object pobjObjectVO)
		{
			const string METHOD_NAME = THIS + ".Add()";
			 
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS =null;
			try
			{
				string strSql = "INSERT INTO PRO_OutsideProcessingMaster("
					+ PRO_OutsideProcessingMasterTable.POSTDATE_FLD + ","
					+ PRO_OutsideProcessingMasterTable.TRANSNO_FLD + ","
					+ PRO_OutsideProcessingMasterTable.CCNID_FLD + ","
					+ PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD + ")"
					+ "VALUES(?,?,?,?)";

				PRO_OutsideProcessingMasterVO objObject = (PRO_OutsideProcessingMasterVO)pobjObjectVO;
				
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);				

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.POSTDATE_FLD, OleDbType.Date));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.POSTDATE_FLD].Value = objObject.PostDate;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.TRANSNO_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.TRANSNO_FLD].Value = objObject.TransNo.Trim();

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.CCNID_FLD].Value = objObject.CCNID;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD].Value = objObject.MasterLocationID;
				
				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
		
		public int AddAndReturnID(object pobjMaster)
		{
			const string METHOD_NAME = THIS + ".AddAndReturnID()";
			 
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS =null;
			try
			{
				string strSql =	"INSERT INTO PRO_OutsideProcessingMaster("
					+ PRO_OutsideProcessingMasterTable.POSTDATE_FLD + ","
					+ PRO_OutsideProcessingMasterTable.TRANSNO_FLD + ","
					+ PRO_OutsideProcessingMasterTable.CCNID_FLD + ","
					+ PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD + ")"
					+ "VALUES(?,?,?,?)";
				strSql += "; Select @@IDENTITY as NEWID";

				PRO_OutsideProcessingMasterVO objObject = (PRO_OutsideProcessingMasterVO)pobjMaster;				
				
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				
				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.POSTDATE_FLD, OleDbType.Date));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.POSTDATE_FLD].Value = objObject.PostDate;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.TRANSNO_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.TRANSNO_FLD].Value = objObject.TransNo.Trim();

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.CCNID_FLD].Value = objObject.CCNID;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD].Value = objObject.MasterLocationID;
				
				ocmdPCS.Connection.Open();

				return int.Parse(ocmdPCS.ExecuteScalar().ToString());
			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		//**************************************************************************              
		///    <Description>
		///       This method uses to update data to PRO_OutsideProcessingMaster
		///    </Description>
		///    <Inputs>
		///       PRO_OutsideProcessingMasterVO       
		///    </Inputs>
		///    <Outputs>
		///       
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       09-Dec-2004
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************
		
	
		public void Update(object pobjObjecVO)
		{
			const string METHOD_NAME = THIS + ".Update()";

			PRO_OutsideProcessingMasterVO objObject = (PRO_OutsideProcessingMasterVO) pobjObjecVO;

			//prepare value for parameters
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = "UPDATE PRO_OutsideProcessingMaster SET "
					+ PRO_OutsideProcessingMasterTable.POSTDATE_FLD + "=   ?" + ","
					+ PRO_OutsideProcessingMasterTable.TRANSNO_FLD + "=   ?" + ","
					+ PRO_OutsideProcessingMasterTable.CCNID_FLD + "=   ?" + ","
					+ PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD + "=  ?"
					+" WHERE " + PRO_OutsideProcessingMasterTable.OUTSIDEPROCESSINGMASTERID_FLD + "= ?";

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);				

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.POSTDATE_FLD, OleDbType.Date));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.POSTDATE_FLD].Value = objObject.PostDate;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.TRANSNO_FLD, OleDbType.VarWChar));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.TRANSNO_FLD].Value = objObject.TransNo.Trim();

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.CCNID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.CCNID_FLD].Value = objObject.CCNID;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD].Value = objObject.MasterLocationID;

				ocmdPCS.Parameters.Add(new OleDbParameter(PRO_OutsideProcessingMasterTable.OUTSIDEPROCESSINGMASTERID_FLD, OleDbType.Integer));
				ocmdPCS.Parameters[PRO_OutsideProcessingMasterTable.OUTSIDEPROCESSINGMASTERID_FLD].Value = objObject.OutsideProcessingMasterID;

				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	
			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}

		}

		//**************************************************************************              
		///    <Description>
		///       This method uses to update a DataSet
		///    </Description>
		///    <Inputs>
		///        DataSet       
		///    </Inputs>
		///    <Outputs>
		///       
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       Tuesday, May 31, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************
		
		public void UpdateDataSet(DataSet pdstData)
		{
			const string METHOD_NAME = THIS + ".UpdateDataSet()";			
			OleDbConnection oconPCS =null;
			OleDbCommandBuilder odcbPCS ;
			OleDbDataAdapter odadPCS = new OleDbDataAdapter();

			try
			{
				string strSql =	"SELECT "
					+ PRO_OutsideProcessingMasterTable.OUTSIDEPROCESSINGMASTERID_FLD + ", "
					+ PRO_OutsideProcessingMasterTable.POSTDATE_FLD + ", "
					+ PRO_OutsideProcessingMasterTable.TRANSNO_FLD + ", "
					+ PRO_OutsideProcessingMasterTable.CCNID_FLD + ", "
					+ PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD 
					+ " FROM " + PRO_OutsideProcessingMasterTable.TABLE_NAME;

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				odadPCS.SelectCommand = new OleDbCommand(strSql, oconPCS);
				odcbPCS = new OleDbCommandBuilder(odadPCS);
				pdstData.EnforceConstraints = false;
				odadPCS.Update(pdstData, PRO_OutsideProcessingMasterTable.TABLE_NAME);
			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLDUPLICATE_KEYCODE)
				{																   
					throw new PCSDBException(ErrorCode.DUPLICATE_KEY, METHOD_NAME, ex);				
				}
				else if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
				{
					throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);				
				}				
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}
			catch(InvalidOperationException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}
			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		//**************************************************************************              
		///    <Description>
		///       This method uses to delete data from PRO_OutsideProcessingMaster
		///    </Description>
		///    <Inputs>
		///        ID       
		///    </Inputs>
		///    <Outputs>
		///       void
		///    </Outputs>
		///    <Returns>
		///       
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       09-Dec-2004
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************

		public void Delete(int pintID)
		{
			const string METHOD_NAME = THIS + ".Delete()";
			
			OleDbConnection oconPCS=null;
			OleDbCommand ocmdPCS =null;
			try
			{
				string strSql = "DELETE " + PRO_OutsideProcessingMasterTable.TABLE_NAME + " WHERE  " + "OutsideProcessingMasterID" + "=" + pintID.ToString();

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				ocmdPCS.ExecuteNonQuery();	
				ocmdPCS = null;

			}
			catch(OleDbException ex)
			{
				if (ex.Errors[1].NativeError == ErrorCode.SQLCASCADE_PREVENT_KEYCODE)
				{
																   
					throw new PCSDBException(ErrorCode.CASCADE_DELETE_PREVENT, METHOD_NAME, ex);				
				}
				else
				{
					throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
				}
			}			

			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}



			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		#endregion Update Data Methods

		#region Retreive Data Methods
	
		//**************************************************************************              
		///    <Description>
		///       This method uses to get data from PRO_OutsideProcessingMaster
		///    </Description>
		///    <Inputs>
		///        ID       
		///    </Inputs>
		///    <Outputs>
		///       PRO_OutsideProcessingMasterVO
		///    </Outputs>
		///    <Returns>
		///       PRO_OutsideProcessingMasterVO
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       Tuesday, May 31, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************

		public object GetObjectVO(int pintID)
		{
			const string METHOD_NAME = THIS + ".GetObjectVO()";
			
			DataSet dstPCS = new DataSet();			
			OleDbDataReader odrPCS = null;
			OleDbConnection oconPCS = null;
			OleDbCommand ocmdPCS = null;

			try 
			{				 
				string strSql =	"SELECT "
						+ PRO_OutsideProcessingMasterTable.OUTSIDEPROCESSINGMASTERID_FLD + ","
						+ PRO_OutsideProcessingMasterTable.POSTDATE_FLD + ","
						+ PRO_OutsideProcessingMasterTable.TRANSNO_FLD + ","
						+ PRO_OutsideProcessingMasterTable.CCNID_FLD + ","
						+ PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD
						+ " FROM " + PRO_OutsideProcessingMasterTable.TABLE_NAME
						+ " WHERE " + PRO_OutsideProcessingMasterTable.OUTSIDEPROCESSINGMASTERID_FLD + "=" + pintID.ToString();

				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);

				ocmdPCS.Connection.Open();
				odrPCS = ocmdPCS.ExecuteReader();

				PRO_OutsideProcessingMasterVO objObject = new PRO_OutsideProcessingMasterVO();

				if(odrPCS.Read())
				{ 
					objObject.OutsideProcessingMasterID = int.Parse(odrPCS[PRO_OutsideProcessingMasterTable.OUTSIDEPROCESSINGMASTERID_FLD].ToString().Trim());
					objObject.PostDate = DateTime.Parse(odrPCS[PRO_OutsideProcessingMasterTable.POSTDATE_FLD].ToString().Trim());
					objObject.TransNo = odrPCS[PRO_OutsideProcessingMasterTable.TRANSNO_FLD].ToString().Trim();
					objObject.CCNID = int.Parse(odrPCS[PRO_OutsideProcessingMasterTable.CCNID_FLD].ToString().Trim());
					objObject.MasterLocationID = int.Parse(odrPCS[PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD].ToString().Trim());
				}
				return objObject;
			}
			catch(OleDbException ex)
			{			
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			

			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}

		//**************************************************************************              
		///    <Description>
		///       This method uses to get all data from PRO_OutsideProcessingMaster
		///    </Description>
		///    <Inputs>
		///               
		///    </Inputs>
		///    <Outputs>
		///       DataSet
		///    </Outputs>
		///    <Returns>
		///       DataSet
		///    </Returns>
		///    <Authors>
		///       HungLa
		///    </Authors>
		///    <History>
		///       Tuesday, May 31, 2005
		///    </History>
		///    <Notes>
		///    </Notes>
		//**************************************************************************

		public DataSet List()
		{
			const string METHOD_NAME = THIS + ".List()";
			DataSet dstPCS = new DataSet();
			
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = "SELECT "
						+ PRO_OutsideProcessingMasterTable.OUTSIDEPROCESSINGMASTERID_FLD + ","
						+ PRO_OutsideProcessingMasterTable.POSTDATE_FLD + ","
						+ PRO_OutsideProcessingMasterTable.TRANSNO_FLD + ","
						+ PRO_OutsideProcessingMasterTable.CCNID_FLD + ","
						+ PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD
						+ " FROM " + PRO_OutsideProcessingMasterTable.TABLE_NAME;
				
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Connection.Open();
				
				OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
				odadPCS.Fill(dstPCS,PRO_OutsideProcessingMasterTable.TABLE_NAME);

				return dstPCS;
			}
			catch(OleDbException ex)
			{
   				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}
		}
				
		/// <summary>
		/// Get full information to load on form, included relate table
		/// </summary>
		/// <param name="pintMasterID"></param>
		/// <returns></returns>
		
		public DataRow GetOutsideProcessingMaster(int pintMasterID)
		{
			const string METHOD_NAME = THIS + ".GetOutsideProcessingMaster()";
			DataSet dstPCS = new DataSet();
			
			OleDbConnection oconPCS =null;
			OleDbCommand ocmdPCS = null;
			try 
			{
				string strSql = "SELECT  "
					+ PRO_OutsideProcessingMasterTable.TABLE_NAME + "." + PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD + ", " 
					+ PRO_OutsideProcessingMasterTable.TABLE_NAME + "." + PRO_OutsideProcessingMasterTable.CCNID_FLD + ", " 
					+ PRO_OutsideProcessingMasterTable.TABLE_NAME + "." + PRO_OutsideProcessingMasterTable.TRANSNO_FLD + ", " 
					+ PRO_OutsideProcessingMasterTable.TABLE_NAME + "." + PRO_OutsideProcessingMasterTable.POSTDATE_FLD + ", " 
					+ PRO_OutsideProcessingMasterTable.TABLE_NAME + "." + PRO_OutsideProcessingMasterTable.OUTSIDEPROCESSINGMASTERID_FLD + ", " 
					+ MST_CCNTable.TABLE_NAME + "." + MST_CCNTable.CODE_FLD + " as " + MST_CCNTable.TABLE_NAME + MST_CCNTable.CODE_FLD +", "
					+ MST_MasterLocationTable.TABLE_NAME + "." + MST_MasterLocationTable.CODE_FLD + " as " + MST_MasterLocationTable.TABLE_NAME + MST_MasterLocationTable.CODE_FLD + ", "
					+ MST_MasterLocationTable.TABLE_NAME + "." + MST_MasterLocationTable.NAME_FLD + " as " + MST_MasterLocationTable.TABLE_NAME +  MST_MasterLocationTable.NAME_FLD
					+ " FROM " + MST_CCNTable.TABLE_NAME 
					+ " INNER JOIN " + PRO_OutsideProcessingMasterTable.TABLE_NAME 
						+ " ON " + MST_CCNTable.TABLE_NAME + "." + MST_CCNTable.CCNID_FLD + " = " + PRO_OutsideProcessingMasterTable.TABLE_NAME + "." + PRO_OutsideProcessingMasterTable.CCNID_FLD 
					+ " INNER JOIN " + MST_MasterLocationTable.TABLE_NAME 
						+ " ON " + PRO_OutsideProcessingMasterTable.TABLE_NAME + "." + PRO_OutsideProcessingMasterTable.MASTERLOCATIONID_FLD + " = " + MST_MasterLocationTable.TABLE_NAME + "." + MST_MasterLocationTable.MASTERLOCATIONID_FLD
					+ " WHERE " + PRO_OutsideProcessingMasterTable.TABLE_NAME + "." + PRO_OutsideProcessingMasterTable.OUTSIDEPROCESSINGMASTERID_FLD + "=" + pintMasterID.ToString();
				
				
				oconPCS = new OleDbConnection(Utils.Instance.OleDbConnectionString);
				ocmdPCS = new OleDbCommand(strSql, oconPCS);
				ocmdPCS.Connection.Open();
				
				OleDbDataAdapter odadPCS = new OleDbDataAdapter(ocmdPCS);
				odadPCS.Fill(dstPCS, PRO_OutsideProcessingMasterTable.TABLE_NAME);

				if(dstPCS.Tables[PRO_OutsideProcessingMasterTable.TABLE_NAME].Rows.Count != 0)
					return dstPCS.Tables[PRO_OutsideProcessingMasterTable.TABLE_NAME].Rows[0];
				else
					return null;
			}
			catch(OleDbException ex)
			{
				throw new PCSDBException(ErrorCode.ERROR_DB, METHOD_NAME,ex);
			}			
			catch (Exception ex) 
			{
				throw new PCSDBException(ErrorCode.OTHER_ERROR, METHOD_NAME, ex);
			}

			finally 
			{
				if (oconPCS!=null) 
				{
					if (oconPCS.State != ConnectionState.Closed) 
					{
						oconPCS.Close();
					}
				}
			}		
		}

		#endregion Retreive Data Methods
	}
}